package com.ksd.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ksd.common.annotation.Log;
import com.ksd.common.core.controller.BaseController;
import com.ksd.common.core.domain.AjaxResult;
import com.ksd.common.core.page.TableDataInfo;
import com.ksd.common.enums.BusinessType;
import com.ksd.common.utils.poi.ExcelUtil;
import com.ksd.system.domain.SysFreqOne;
import com.ksd.system.service.ISysFreqOneService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 频点参数Controller
 * 
 * @author y.wu
 * @date 2025-02-08
 */
@RestController
@RequestMapping("/system/freq")
public class SysFreqController extends BaseController
{
    @Autowired
    private ISysFreqOneService sysFreqService;

    /**
     * 查询频点参数列表
     */
    @PreAuthorize("@ss.hasPermi('system:freq:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysFreqOne sysFreq)
    {
        startPage();
        List<SysFreqOne> list = sysFreqService.selectSysFreqList(sysFreq);
        return getDataTable(list);
    }

    /**
     * 导出频点参数列表
     */
    @PreAuthorize("@ss.hasPermi('system:freq:export')")
    @Log(title = "频点参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysFreqOne sysFreq)
    {
        List<SysFreqOne> list = sysFreqService.selectSysFreqList(sysFreq);
        ExcelUtil<SysFreqOne> util = new ExcelUtil<SysFreqOne>(SysFreqOne.class);
        util.exportExcel(response, list, "频点参数数据");
    }

    /**
     * 获取频点参数详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:freq:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysFreqService.selectSysFreqById(id));
    }

    /**
     * 新增频点参数
     */
    @PreAuthorize("@ss.hasPermi('system:freq:add')")
    @Log(title = "频点参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysFreqOne sysFreq)
    {
        return toAjax(sysFreqService.insertSysFreq(sysFreq));
    }

    /**
     * 修改频点参数
     */
    @PreAuthorize("@ss.hasPermi('system:freq:edit')")
    @Log(title = "频点参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysFreqOne sysFreq)
    {
        return toAjax(sysFreqService.updateSysFreq(sysFreq));
    }

    /**
     * 删除频点参数
     */
    @PreAuthorize("@ss.hasPermi('system:freq:remove')")
    @Log(title = "频点参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysFreqService.deleteSysFreqByIds(ids));
    }
}
